package com.yuan.demo01_test;

import com.yuan.pojo.User;
import com.yuan.utils.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

import java.sql.SQLException;


public class Demo01{
    private static Logger logger=LogManager.getLogger(Demo01.class.getName());
    @Test
    public void insert(){

    }

    @Test
    public void select() throws SQLException {


        QueryRunner queryRunner = new QueryRunner(DruidUtil.getDataSource());
        Long queryCount = (Long) queryRunner.query("select count(*) from user", new ScalarHandler());
        System.out.println(queryCount);
        logger.debug(queryCount);
        //log4j.jar
    }

}
